<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style media="screen">
        body {
            background: #000;
        }
        #svg {
            background: #fff;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <svg id="svg" width="800" height="600">
        <line x1="100" y1="100" x2="300" y2="300" style="stroke:red;stroke-width:20" id="line"></line>
    </svg>
    <script type="text/javascript">
        let line = document.querySelector('#line');

        line.addEventListener('mouseover', function() {
            this.style.stroke = 'yellow';
        })

        line.addEventListener('mouseout', function() {
            this.style.stroke = 'red';
        })
    </script>
</body>
</html>
